import axios from 'axios'
// axios实例
const instance = axios.create({
    baseURL: '/api',
    timeout: 60000,
    headers: { 'Content-Type': 'application/json;charset=UTF-8' }
})

export const get = (url, params = {}) => {
    return new Promise((resolve, reject) => {
      instance.get(url, { params }).then(
        response => {
          resolve(response.data)
        },
        err => {
          reject(err)
        }
      )
    })
}
  
export const post = (url, data = {}) => {
    return new Promise((resolve, reject) => {
      instance
        .post(url, data)
        .then(
          response => {
            resolve(response.data)
          },
          err => {
            reject(err)
          }
        )
    })
}